package com.yaoli.ajob;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by will on 2017/4/6.
 */
public class _137_SingleNumberII {
    public static void main(String[] args) {
        _137_SingleNumberII singleNumberII = new _137_SingleNumberII();

        int nums [] = {2,2,3,2};


        singleNumberII.singleNumber(nums);
    }

    public int singleNumber(int[] nums) {
        Map<Integer,Integer> map = new HashMap<Integer,Integer>();

        for(int i = 0 ; i < nums.length ; i ++){
            Integer temp = map.get(nums[i]);
            if(temp == null){
                map.put(nums[i],1);
            }else if(temp == 2){
                map.remove(nums[i]);
            }else{
                map.put(nums[i],2);
            }
        }

        for(Integer c:map.keySet()){
            return map.get(c);
        }

        return 0;
    }
}
